﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FinalProject.UI
{
    /// <summary>
    /// Interaction logic for VoucherPage.xaml
    /// </summary>
    public partial class VoucherPage : UserControl, IBasePage
    {
        private DataGridCheckBoxColumn colDetailSelect;
        private DataGridTextColumn colDetailInvoiceNum,
            colDetailInvoiceDate,
            colDetailAmount,
            colDetailDescrip;

        private DataGridTextColumn
            colVoucherId,
            colVoucherJournal,
            colVoucherNum,
            colVoucherDate,
            colVoucherCust,
            colVoucherTotal,
            colVoucherCurrency,
            colVoucherDescrip;

        public VoucherPage()
        {
            this.InitializeComponent();
            this.InitializedColumGridDetail();
            this.InitilizeGridVoucher();
        }

        private void InitializedColumGridDetail()
        {
            this.colDetailSelect = new DataGridCheckBoxColumn()
            {
                Header = "Selected",
                Binding = new Binding("Checked"),
                IsReadOnly = false,
                Width = 80
            };
            this.grvDetail.Columns.Add(this.colDetailSelect);

            this.colDetailInvoiceNum = new DataGridTextColumn()
            {
                Header = "Invoice Number",
                Binding = new Binding("InvoiceNumber"),
                IsReadOnly = true,
                Width = 130
            };
            this.grvDetail.Columns.Add(this.colDetailInvoiceNum);

            this.colDetailInvoiceDate = new DataGridTextColumn()
            {
                Header = "Invoice Date",
                Binding = new Binding("InvoiceDate"),
                IsReadOnly = true,
                Width = 130
            };
            this.grvDetail.Columns.Add(this.colDetailInvoiceDate);

            this.colDetailAmount = new DataGridTextColumn()
            {
                Header = "Amount",
                Binding = new Binding("Amount"),
                IsReadOnly = false,
                Width = 130
            };
            this.grvDetail.Columns.Add(this.colDetailAmount);

            this.colDetailDescrip = new DataGridTextColumn()
            {
                Header = "Description",
                Binding = new Binding("Description"),
                IsReadOnly = false,
                Width = 250,
            };
            this.grvDetail.Columns.Add(this.colDetailDescrip);
        }

        private void InitilizeGridVoucher()
        {
            this.grvVoucherList.IsReadOnly = true;
            this.colVoucherId = new DataGridTextColumn()
            {
                Header = string.Empty,
                Binding = new Binding("Id"),
                Visibility = System.Windows.Visibility.Hidden,
            };
            this.grvVoucherList.Columns.Add(this.colVoucherId);

            this.colVoucherJournal = new DataGridTextColumn()
            {
                Header = "Journal",
                Binding = new Binding("JournalCode"),
                IsReadOnly = true,
                Width = 120
            };
            this.grvVoucherList.Columns.Add(this.colVoucherJournal);

            this.colVoucherNum = new DataGridTextColumn()
            {
                Header = "Number",
                Binding = new Binding("InvoiceNumber"),
                IsReadOnly = true,
                Width = 120
            };
            this.grvVoucherList.Columns.Add(this.colVoucherNum);

            this.colVoucherDate = new DataGridTextColumn()
            {
                Header = "Date",
                Binding = new Binding("InvoiceDate"),
                IsReadOnly = true
            };
            this.grvVoucherList.Columns.Add(this.colVoucherDate);

            this.colVoucherCust = new DataGridTextColumn()
            {
                Header = "Customer",
                Binding = new Binding("CustomerCode"),
                Width = 120
            };
            this.grvVoucherList.Columns.Add(this.colVoucherCust);

            this.colVoucherTotal = new DataGridTextColumn()
            {
                Header = "Total",
                Binding = new Binding("TotalAmount"),
                Width = 150
            };
            this.grvVoucherList.Columns.Add(this.colVoucherTotal);

            this.colVoucherCurrency = new DataGridTextColumn()
            {
                Header = "Currency",
                Binding = new Binding("Currency"),
                Width = 150
            };
            this.grvVoucherList.Columns.Add(this.colVoucherCurrency);

            this.colVoucherDescrip = new DataGridTextColumn()
            {
                Header = "Description",
                Binding = new Binding("Description"),
                Width = 200
            };
            this.grvVoucherList.Columns.Add(this.colVoucherDescrip);
        }

        public void SaveData()
        {
        }

        public void CancelModified()
        {
        }

        public void ChangeToNewMode()
        {
        }

        public void ChangeToNormalMode()
        {
        }
    }
}